<template>
	<view class="app">
		<uni-card :title="list.title" extra="">
			<text class="uni-body">
				<view class="title1">
					佣金：{{list.yongjin}}&nbsp;元
				</view>
				<br />
				<view class="title1">
					支付方式：{{list.qudao}}
				</view>
				<br />
				<view class="title1">
					发布人：{{list.username}}
				</view>
				<br />
				<view class="title1">
					支付通道：
				</view>
				<br />
				<cover-image :src="'http://127.0.0.1:8089/intool/' + list.images"></cover-image>
			</text>
		</uni-card>
		<view class="tijiao" v-if="list.status != '待审核' && list.status != '通过'">
			<uni-forms ref="baseForm" :model="baseFormData" labelWidth="160rpx" class="form">
				<uni-forms-item label="交易证明">
					<uni-file-picker fileMediatype="image" :limit="1" mode="grid" @select="uloadFile" />
				</uni-forms-item>
			</uni-forms>
			<button class="button" type="primary" @click="tijiao(list.id)">提交任务</button>
		</view>
		<view class="tijiao1" v-if="list.status == '待审核'">
			<cover-image :src="'http://127.0.0.1:8089/intool/' + list.zhengming"></cover-image>
			<button class="button" type="primary" disabled="">审核中</button>
		</view>
		<view class="tijiao1" v-if="list.status == '通过'">
			<cover-image :src="'http://127.0.0.1:8089/intool/' + list.zhengming"></cover-image>
			<button class="button" type="primary" disabled="">已通过</button>
		</view>
	</view>
</template>

<script>
	import {
		baseDefaultUrl
	} from '../../config/config'
	export default {
		data() {
			return {
				list: {},
				zhengming: ''
			}
		},
		onShow() {
			uni.request({
				url: baseDefaultUrl + "/inter/t-work/get_myl?id=" + this.$route.query.id,
				method: 'GET',
				header: {
					"Authorization": uni.getStorageSync('token')
				},
				success: (res) => {
					if (res.data.code != 0) {
						this.list = res.data.data
						this.list.username = this.list.username.slice(0, 3) + '****' + this.list.username
						console.log(this.list)
							.slice(-4)
					} else {
						uni.showToast({
							title: res.data.message,
							icon: 'error'
						});
					}
				}
			})
		},
		methods: {
			uloadFile(e) {
				const tempFilePaths = e.tempFilePaths;
				uni.uploadFile({
					url: baseDefaultUrl + '/inter/upload/fileUp',
					filePath: tempFilePaths[0],
					name: 'file',
					// formData: {
					// 	'user': 'test'
					// },
					success: (uploadFileRes) => {
						console.log(uploadFileRes.data);
						let ress = JSON.parse(uploadFileRes.data)
						this.zhengming = ress.data
					}
				});
			},
			tijiao() {
				uni.request({
					url: baseDefaultUrl + "/inter/t-work/t_work",
					method: 'GET',
					data: {
						"zhengming": this.zhengming,
						"userWorkId": this.list.id
					},
					header: {
						"Authorization": uni.getStorageSync('token')
					},
					success: (res) => {
						if (res.data.code != 0) {
							uni.navigateBack({
								delta: 1,
								success: function() {
									setTimeout(function() {
										uni.showToast({
											title: "提交成功",
											icon: 'success',
											duration: 2000
										});
									}, 500);
								}
							});
						} else {
							uni.showToast({
								title: res.data.message,
								icon: 'error'
							});
						}
					}
				})
			},
		}
	}
</script>

<style scoped>
	/deep/ .uni-card .uni-card__header .uni-card__header-content .uni-card__header-content-title {
		font-size: 40rpx;
		font-weight: bolder;
		line-height: 60rpx;
	}

	.title1 {
		font-size: 30rpx;
		font-weight: bolder;
		color: black;
	}

	.tijiao {
		padding: 30rpx;
	}

	.tijiao1 {
		padding: 30rpx;
	}

	.tijiao1 button {
		margin-top: 20rpx;
	}
</style>